chore: use isinstance() instead of type comparison#1792
Draft
Conversation
atulep
reviewed
Jun 15, 2022
| A string representation of 'value' based on the schema_type. | ||
| """ | ||
| if schema_type == "string": | ||
| if type(value) == type("") or type(value) == type(""): |
There was a problem hiding this comment.
This looks weird, but also potentially unsafe to remove.
There was a problem hiding this comment.
This is indeed weird, but is also safe.
Look at the last time it was changed (you will have to expand discover.py and scroll to line 701): 3bbefc1#diff-b039ba2bb64e79cf4c77e4fe5a4b21a826172e8b7ae9be872fd2d46047c05cbbL695-R701
Originally, it was
if type(value) == type("") or type(value) == type(u""):But was changed automatically to be
if type(value) == type("") or type(value) == type(""):because type("") == type(u"") == "str".
This if is redundant and pretty silly, and should be changed, no?
whoami-anoint
approved these changes
Aug 7, 2023
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes warning from
flake8 . --select E721